package com.zzl.bonds.ticket.controller;

import com.zzl.apidoc.annotation.ApidocController;
import com.zzl.apidoc.annotation.ApidocOperation;
import com.zzl.apidoc.annotation.ApidocParam;
import com.zzl.bonds.ticket.dto.SubsidiaryQuotaUpdateDto;
import com.zzl.bonds.ticket.service.SubsidiaryQuotaService;
import com.zzl.general.common.apidoc.annotation.ApidocReturnR;
import com.zzl.general.common.ctrl.WebBaseCtrl;
import com.zzl.general.common.exception.SysException;
import com.zzl.general.common.utils.LogUtils;
import com.zzl.general.common.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分公司集团授信额度管理
 *
 * @author sunpp
 * @date 2022-03-01 11:26:07
 */
@ApidocController("5分公司集团授信额度管理")
@RestController
@SuppressWarnings("javadoc")
@RequestMapping("bondsticket/subsidiaryquota")
@Slf4j
public class SubsidiaryQuotaController extends WebBaseCtrl {
    @SuppressWarnings("all")
    @Autowired
    private SubsidiaryQuotaService subsidiaryQuotaService;

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApidocOperation(description = "1修改分公司的授信", operationId = "/ticket/subsidiaryquota/update")
    @ApidocReturnR
    public Result update(@ApidocParam(name = "修改的分公司集团授信额度管理对象值", required = true) @RequestBody SubsidiaryQuotaUpdateDto subsidiaryQuota) {
        try {
            subsidiaryQuotaService.updateSubsidiaryQuotaById(subsidiaryQuota, this.getUser());
            return Result.ok();
        } catch (SysException e) {
            LogUtils.logSysException(log, e);
            return Result.error(e.getMsg());
        }
    }

}
